home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-02-27 | 2.2 KB | 114 lines | [TEXT/BROW] |
- //
- // File: update.c
- //
- // This file contains routines to manage the update from the offscreen to the screen.
- //
- // 2/19/95 -- Created by Mick
- //
-
- // include files
-
- #include "global.h"
-
- #include "update.h"
-
- // defines for this file
-
- // global function declarations
-
- void clearUpdate( void );
- void addRectToUpdate( Rect *inUpdateRect );
- unsigned char getUpdateRect( Rect *outUpdateRect );
-
- // global data owned by this file
-
- // local function declarations
-
- static void adjustRect( Rect *ioRect );
-
- // static data
-
- static Rect sDirtyRect; // the rect that needs to be udpated
- static unsigned char sIsDirty; // is there a dirty rect?
-
- // functions
-
-
- //
- // clearUpdate -
- //
- // Resets the update to none.
- //
-
- void clearUpdate( void )
- {
- // note that there is no dirty rect
- sIsDirty = kFalse;
- }
-
-
- //
- // addRectToUpdate -
- //
- // Adds a rect to the update area.
- //
-
- void addRectToUpdate( Rect *inUpdateRect )
- {
- // if there is an update rect already
- if( sIsDirty )
- {
- // add this one to it
- sDirtyRect.top = sDirtyRect.top < inUpdateRect->top ? sDirtyRect.top : inUpdateRect->top;
- sDirtyRect.left = sDirtyRect.left < inUpdateRect->left ? sDirtyRect.left : inUpdateRect->left;
- sDirtyRect.bottom = sDirtyRect.bottom > inUpdateRect->bottom ? sDirtyRect.bottom : inUpdateRect->bottom;
- sDirtyRect.right = sDirtyRect.right > inUpdateRect->right ? sDirtyRect.right : inUpdateRect->right;
-
- // adjust the rect to 32 bit bounds
- adjustRect( &sDirtyRect );
- }
- else
- {
- // make this the dirty rect
- sDirtyRect = *inUpdateRect;
-
- // note that there is a dirty rect
- sIsDirty = kTrue;
-
- // adjust the rect to 32 bit bounds
- adjustRect( &sDirtyRect );
- }
- }
-
-
- //
- // getUpdateRect -
- //
- // Get the dirty rect. If there is one the return is true, otherwise false.
- //
-
- unsigned char getUpdateRect( Rect *outUpdateRect )
- {
- // if there is an update rect, send it out
- if ( sIsDirty )
- {
- *outUpdateRect = sDirtyRect;
- }
-
- // return the dirty flag
- return sIsDirty;
- }
-
-
- //
- // adjustRect -
- //
- // Move the left and right sides to 32 bit boundrys. This will speed up CopyBits.
- //
-
- void adjustRect( Rect *ioRect )
- {
- // expand the rect so its horizontal sides are on 32 bit bounds
- ioRect->left = ioRect->left & 0xfffC;
- ioRect->right = ( ioRect->right + 3 ) & 0xfffC;
- }